package com.pucong.gitee.database.backup.database.util;

import com.pucong.gitee.database.backup.common.entity.BackupDatabase;
import com.pucong.gitee.database.backup.common.selfenum.DatabaseTypeEnum;
import com.pucong.gitee.database.backup.database.mapper.BackupExeSqlLogMapper;

public class BackupServiceFactory {

    /**
     * 工厂生产sql执行器
     * @param backupDatabase
     * @param backupExeSqlLogMapper
     * @return
     */
    public BackupService getBackupService(BackupDatabase backupDatabase, BackupExeSqlLogMapper backupExeSqlLogMapper) {
        DatabaseTypeEnum databaseType = backupDatabase.getDatabaseType();
        BackupService backupService = null;
        switch (databaseType){
            case oracle:
                backupService = new BackupServiceOracleImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case mysql:
                backupService = new BackupServiceMysqlImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case postgresql:
                backupService = new BackupServicePgsqlImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case sqlserver:
                backupService = new BackupServiceMssqlImpl(backupDatabase,backupExeSqlLogMapper);
                break;
            case hive:
                backupService = new BackupServiceHivelImpl(backupDatabase,backupExeSqlLogMapper);
                break;
        }
        return backupService;
    }

}